<template>
    <div class="bind-box">
        <navBar :navTitle="$t('Bangdingyinhang')" />
        <van-form ref="refFormCard" class="full-width92 public-form public-form-label">
            <van-field v-model.trim="formCard.card_name" class="bg-inp" :placeholder="$t('Chikaren')"
                :label="$t('Chikaren')" :rules="[{ required: true, message: $t('Qingshuru') + $t('Chikaren') }]" />
            <van-field v-model.trim="formCard.card_id" class="bg-inp" :placeholder="$t('Yinhangzhanghu')"
                :label="$t('Yinhangzhanghu')"
                :rules="[{ required: true, message: $t('Qingshuru') + $t('Yinhangzhanghu') }]" />
            <van-field v-model.trim="formCard.card_type" class="bg-inp" :placeholder="$t('Yinhangmingcheng')"
                :label="$t('Yinhangmingcheng')"
                :rules="[{ required: true, message: $t('Qingshuru') + $t('Yinhangmingcheng') }]" />
            <van-field v-model.trim="formCard.card_branch" class="bg-inp" :placeholder="$t('Zhihang')"
                :label="$t('Zhihang')" :rules="[{ required: true, message: $t('Qingshuru') + $t('Zhihang') }]" />
            <van-field v-model.trim="formCard.branch_number" class="bg-inp" :placeholder="$t('Yinhangdaima')"
                :label="$t('Yinhangdaima')" :rules="[{ required: true, message: $t('Qingshuru') + $t('Yinhangdaima') }]" />
            <van-button block type="info" native-type="submit" class="marTop40" @click="fnBtnSave('refFormCard')"
                v-btn-re-click>{{ $t('Fasong') }}</van-button>
        </van-form>
    </div>
</template>

<script>
import { qcard_add_api } from "@/assets/js/api";

export default {
    name: "myCardManage_Bind.vue",
    data() {
        return {
            formCard: {
                quser_id: "",
                card_name: "", //招商
                card_id: "", //48754126457451247
                card_type: "", //信用卡
                card_branch: "", //深圳分行
                branch_number: "", //sz100
            },
        }
    },
    methods: {
        /*保存綁定*/
        fnBtnSave(refForm) {
            this.$refs[refForm].validate().then(() => {
                qcard_add_api(this.formCard).then(res => {
                    if (res.code == 200) {
                        this.$toast(res.msg || "Ràng buộc thành công！");
                        setTimeout(() => {
                            this.$router.push({
                                name: "my_cardManage"
                            })
                        }, 1000)
                    }
                })
            }).catch(res => { })
        },
    },
    created() {
        this.formCard.quser_id = localStorage.getItem("userId");
    },
}
</script>
<style>
.bind-box .van-cell {
    height: 4em;
    overflow: visible;
}

</style>